//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    public class Protection : IOfficeXmlSerializable
    {
        private const string xmlName = "protection";


        private bool _chartObject;

        private bool _data;

        private bool _formatting;

        private bool _selection;

        private bool _userInterface;

        public bool ChartObject
        {
            get { return _chartObject; }
            set { _chartObject = value; }
        }

        public bool Data
        {
            get { return _data; }
            set { _data = value; }
        }

        public bool Formatting
        {
            get { return _formatting; }
            set { _formatting = value; }
        }

        public bool Selection
        {
            get { return _selection; }
            set { _selection = value; }
        }

        public bool UserInterface
        {
            get { return _userInterface; }
            set { _userInterface = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read(xmlName))
            {
                ChartObject = c.ReadOptionalElementBooleanAttribute("chartObject", false);
                Data = c.ReadOptionalElementBooleanAttribute("data", false);
                Formatting = c.ReadOptionalElementBooleanAttribute("formatting", false);
                Selection = c.ReadOptionalElementBooleanAttribute("selection", false);
                UserInterface = c.ReadOptionalElementBooleanAttribute("userInterface", false);
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write(xmlName))
            {
                c.WriteOptionalElementBooleanAttribute("chartObject", ChartObject);
                c.WriteOptionalElementBooleanAttribute("data", Data);
                c.WriteOptionalElementBooleanAttribute("formatting", Formatting);
                c.WriteOptionalElementBooleanAttribute("selection", Selection);
                c.WriteOptionalElementBooleanAttribute("userInterface", UserInterface);
            }
        }

        #endregion
    }
}